<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        console.log(Math.random());
        let date = new Date();
        console.log(date);
        console.log(date.getFullYear());
        console.log(date.getMonth());
        console.log(date.getDate());

        let obj = {
            name:"张飞",
            age :20,
            intro:function(){
                console.log(`我的名字是：${this.name}，今年${this.age}岁`);
            }
        }
        console.log(obj.name);
        console.log(obj["age"]);
        obj.intro();

        // json对象和字符串之间的转换
        // json对象转字符串
        let str = JSON.stringify(obj);
        console.log("str：",str);

        // 字符串转JSON
        let obj1 = JSON.parse(`{"gender":"男"}`);
        console.log(obj1);

        let students = [
            {name:"张飞"},
            {name:"关羽"},
            {name:"刘备"},
            {name:"曹操"},
            {name:"诸葛亮"}
        ]
        console.log(JSON.stringify(students));

        let [a,b,c] = [10,20,30];
        console.log(a,b,c);

        // 解构
        let {name:myName,age:myAge} = obj;
        console.log(myName,myAge);

        // 扩展运算符：...
        // 用法1：不确定形参数量
        // 用法2：将对象的属性扩展出来赋值给另外一个对象
        function f1(...args){
            // console.log(arguments);
            console.log(args);
            
        }
        f1(1,2);
        let newObj = {...obj};
        let newObj1 = obj;
        console.log(newObj == newObj1);
    </script>
</body>
</html>